﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;


namespace DoxygenBrowserAddin.SecurityZones
{
	class InternetSecurityManager : ZoneTestCOM.IServiceProviderForIInternetSecurityManager, ZoneTestCOM.IInternetSecurityManager
	{
		#region IServiceProviderForIInternetSecurityManager
		int ZoneTestCOM.IServiceProviderForIInternetSecurityManager.QueryService(ref Guid guidService, ref Guid riid, out ZoneTestCOM.IInternetSecurityManager ppvObject)
		{
			ppvObject = null;
			if (guidService == ZoneTestCOM.IID_IInternetSecurityManager)
			{
				ppvObject = this as ZoneTestCOM.IInternetSecurityManager;
				return ZoneTestCOM.S_OK;
			}
			return ZoneTestCOM.E_NOINTERFACE;
		}
		#endregion

		#region IInternetSecurityManager
		int ZoneTestCOM.IInternetSecurityManager.SetSecuritySite(ZoneTestCOM.IInternetSecurityMgrSite pSite)
		{
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}

		int ZoneTestCOM.IInternetSecurityManager.GetSecuritySite(ZoneTestCOM.IInternetSecurityMgrSite pSite)
		{
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}

		int ZoneTestCOM.IInternetSecurityManager.MapUrlToZone(String pwszUrl, out int pdwZone, int dwFlags)
		{
			pdwZone = 0;
			Uri uri = new Uri(pwszUrl);
			if(uri.IsLoopback)
			{
				pdwZone = (int)ZoneTestCOM.URLZONE.URLZONE_LOCAL_MACHINE;
				return ZoneTestCOM.S_OK;
			}
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}

		int ZoneTestCOM.IInternetSecurityManager.GetSecurityId(string pwszUrl, byte[] pbSecurityId, ref uint pcbSecurityId, uint dwReserved)
		{
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}

		int ZoneTestCOM.IInternetSecurityManager.ProcessUrlAction(String pwszUrl, int dwAction, IntPtr pPolicy, int cbPolicy, byte pContext, int cbContext, int dwFlags, int dwReserved)
		{
			pPolicy = (IntPtr)0;
			Uri uri = new Uri(pwszUrl);
			if (uri.IsLoopback)
			{
				pPolicy = (IntPtr)0;
				return ZoneTestCOM.S_OK;
			}
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}

		int ZoneTestCOM.IInternetSecurityManager.QueryCustomPolicy(String pwszUrl, ref Guid guidKey, byte ppPolicy, int pcbPolicy, byte pContext, int cbContext, int dwReserved)
		{
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}

		int ZoneTestCOM.IInternetSecurityManager.SetZoneMapping(int dwZone, String lpszPattern, int dwFlags)
		{
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}

		int ZoneTestCOM.IInternetSecurityManager.GetZoneMappings(int dwZone, out UCOMIEnumString ppenumString, int dwFlags)
		{
			ppenumString = null;
			return ZoneTestCOM.INET_E_DEFAULT_ACTION;
		}
		#endregion


	}
}
